﻿#pragma warning(disable: 4477)
#pragma warning(disable: 4996)
#pragma warning(disable: 6031)
#pragma warning(disable: 6054)
/*

 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

typedef long long int64;

typedef struct Rational_s {
	int sgn;
	int i;
	int64 numerator;		//分子
	int64 denominator;		//分母
}Rational;

typedef struct TContext_s
{
	int n;
	Rational v[101];
}TContext;

TContext context;

void swap(int64* a, int64* b)
{
	int64 c = *a;
	*a = *b;
	*b = c;
}

int64 gcd(int64 a, int64 b)
{
	int64 c;
	if (a < b)
		swap(&a, &b);
	if (b == 0)
		return 0;
	while (a % b)
	{
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}

Rational* rational_add(Rational* a, Rational* b)
{
	int64 c = gcd(a->denominator, b->denominator);
	a->numerator = b->denominator / c * a->numerator + a->denominator / c * b->numerator;
	a->denominator /= c;
	a->denominator *= b->denominator;
	if (a->numerator < 0)
		a->sgn = -1;
	else
		a->sgn = 1;
	c = gcd(a->denominator, a->numerator * a->sgn);
	if (c == 0) {
		a->numerator = 0;
		a->denominator = 1;
	}
	else {
		a->denominator /= c;
		a->numerator /= c;
	}
	return a;
}

Rational read_rational()
{
	char a[255];
	char* buf = a;
	scanf("%s", a);
	Rational r = { 0 };
	int sgn = 1;
	if (buf[0] == '-') {
		sgn = -1;
		++buf;
	}
	char* d = strchr(buf, '/');
	r.denominator = atoi(d + 1);
	*d = 0;
	r.numerator = atoi(buf) * sgn;
	return r;
}

void read_data(TContext* ctx)
{
	scanf("%d ", &ctx->n);
	for (int i = 0; i < ctx->n; ++i)
		ctx->v[i] = read_rational();
}

void dump_rational(Rational* a)
{
	if (a->numerator == 0) {
		printf("0\n");
		return;
	}
	else if (a->numerator < 0)
		{
		printf("-");
		a->numerator = -a->numerator;
	}
	int64 c = a->numerator / a->denominator;
	a->numerator %= a->denominator;
	if (c)
		if (a->numerator)
			printf("%d ", c);
		else
			printf("%d", c);
	if (a->numerator)
		printf("%d/%d\n", a->numerator % a->denominator, a->denominator);
}

void do_task(TContext* ctx)
{
	Rational a = ctx->v[0];
	for (int i = 1; i < ctx->n; ++i)
		rational_add(&a, ctx->v + i);
	dump_rational(&a);
}

void solve(TContext* ctx)
{
	read_data(ctx);
	do_task(ctx);
}

int main()
{
	freopen("D:/Develop/GitRepos/MOOC/浙江大学/数据结构/201906/DataStructure/M2019秋C入门和进阶练习集/7-121.txt", "r", stdin);
	solve(&context);
	return 0;
}
